home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic 5 Developer's Kit / vb5 dev kit.iso / dev / f1ocx / vcform1.2 / VB4 / FORMAT1 / format1.bas next >
Encoding:
BASIC Source File  |  1995-09-15  |  24.1 KB  |  678 lines

  1. Attribute VB_Name = "Cell_Formatting"
  2. '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  3. '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  4. ''
  5. '' Cell_Formatting Module for Visual Basic 4
  6. ''
  7. '' This module provides a higher level view to cell formatting
  8. '' which you can simply add to your project. It uses a set
  9. '' of assumptions that are general enough to apply to many
  10. '' cases. It could be placed in a project to allow some fast
  11. '' formatting when you need to generate a prototype quickly.
  12. '' When time permits, you can prune the unecessary parts or
  13. '' just extract the relevant code.
  14. ''
  15. '' How to use the module:
  16. ''    1. Start the demo program and push buttons until you
  17. ''       find a suitable format.
  18. ''    2. Look up the function that does the formatting in the
  19. ''       cmdFormat_Click Event Handler.
  20. ''    3. Add this module to your project.
  21. ''    4. Add the function that does the formatting to the
  22. ''       applicable part of your code
  23. ''    5. Modify as necessary to fit your needs
  24. ''
  25. '' How does it work:
  26. ''    The data is broken into five ranges:
  27. ''       1. The Selection, which is all data to be formatted
  28. ''       2. The hdrRange, which is the top row and contains
  29. ''          column header text
  30. ''       3. The ftrRange, which is the bottom row and usually
  31. ''          contains a summary formula (like =sum(c2:c7)).
  32. ''       4. The col1Range, the left column that usually
  33. ''          contains row header text.
  34. ''       5. The bodyRange, which is the Selection without
  35. ''          the other 3 ranges - normally contains the data.
  36. ''
  37. ''    Most tables can be formatted using these ranges. The
  38. ''    idea is to select the table area and then call
  39. ''    FormatCells with the constant that specifies the
  40. ''    format you want. FormatCells first breaks the selection
  41. ''    into ranges 2, 3, 4, and 5 above. It then calls simplified
  42. ''    versions of the Formula One formatting functions to
  43. ''    create the desired format.
  44. ''
  45. ''    To extend this module, you should find a format that
  46. ''    is similiar to the one you want, define a constant for
  47. ''    it, copy and rename the case in FormatCells that handles
  48. ''    it, and modify it as necessary.
  49. ''
  50. ''    To define a new pattern, start the Workbook Designer and
  51. ''    select Format Pattern... from the Format menu. Select
  52. ''    a pattern, foreground, and background that gives the
  53. ''    desired effect in the pattern sample. Now, count by
  54. ''    rows from the left to find the pattern and color index that
  55. ''    you have selected. The patterns are zero based and the
  56. ''    palette is 1 based. Use PaletteEntry(?) to set the
  57. ''    color in the SetPattern method. Currently, all the
  58. ''    OLE data types (like OLE_COLOR) are undefined in VB 4
  59. ''    so use a long instead.
  60. ''
  61. '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  62. '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  63. Option Explicit
  64.  
  65. '' Constants for the Format types
  66. Global Const SIMPLE = 0
  67. Global Const CLASSIC1 = 1
  68. Global Const CLASSIC2 = 2
  69. Global Const CLASSIC3 = 3
  70. Global Const ACCOUNTING1 = 4
  71. Global Const ACCOUNTING2 = 5
  72. Global Const ACCOUNTING3 = 6
  73. Global Const COLORFUL1 = 7
  74. Global Const COLORFUL2 = 8
  75. Global Const COLORFUL3 = 9
  76. Global Const COLORFUL4 = 10
  77. Global Const LIST1 = 11
  78. Global Const LIST2 = 12
  79. Global Const LIST3 = 13
  80. Global Const EFFECTS3D1 = 14
  81. Global Const EFFECTS3D2 = 15
  82.  
  83. Public Sub FormatCells(SS As Object, how%)
  84. '' This routine formats the sheet. A little extra work is done so it will
  85. '' be easy to apply this code to any selection.
  86.    Dim hdrRange$, ftrRange$, col1Range$, bodyRange$, savedSelection$, i&
  87.  
  88.    With SS
  89.       '' To make this work with any selection you will want to enable
  90.       '' selections, scrollbars, and remove the following line.
  91.       .SetSelection 2, 2, 8, 6
  92.       '' Clear all formats
  93.       .EditClear 2
  94.       hdrRange = GetHdrRangeFromSelection(SS)
  95.       ftrRange = GetFtrRangeFromSelection(SS)
  96.       col1Range = GetCol1RangeFromSelection(SS)
  97.       bodyRange = GetBodyRangeFromSelection(SS)
  98.  
  99.       '' All functions below preserve the initial seleciton
  100.       Select Case how
  101.          Case SIMPLE:     ' Simple
  102.             Call TopMediumBorder(SS, hdrRange, 0)
  103.             Call BottomMediumBorder(SS, ftrRange, 0)
  104.             Call TopThinBorder(SS, ftrRange, 0)
  105.             Call BottomThinBorder(SS, hdrRange, 0)
  106.             Call AdjustFont(SS, hdrRange, 0, True, False, False)
  107.             Call AlignCenter(SS, hdrRange)
  108.  
  109.          Case CLASSIC1:     ' Classic 1
  110.             Call TopMediumBorder(SS, hdrRange, 0)
  111.             Call BottomMediumBorder(SS, ftrRange, 0)
  112.             Call TopThinBorder(SS, ftrRange, 0)
  113.             Call BottomThinBorder(SS, hdrRange, 0)
  114.             Call RightThinBorder(SS, col1Range, 0)
  115.             Call AdjustFont(SS, hdrRange, 0, False, True, False)
  116.             Call AlignCenter(SS, hdrRange)
  117.  
  118.          Case CLASSIC2:     ' Classic 2
  119.             Call TopMediumBorder(SS, hdrRange, 0)
  120.             Call BottomMediumBorder(SS, ftrRange, 0)
  121.             Call TopThinBorder(SS, ftrRange, 0)
  122.             Call BottomThinBorder(SS, hdrRange, 0)
  123.             Call SetSolidPattern(SS, col1Range, .PaletteEntry(15), 0)
  124.             Call SetSolidPattern(SS, hdrRange, .PaletteEntry(13), 0)
  125.             Call AdjustFont(SS, hdrRange, RGB(255, 255, 255), False, False, False)
  126.             Call AdjustFont(SS, col1Range, 0, True, False, False)
  127.             Call AlignCenter(SS, hdrRange)
  128.  
  129.          Case CLASSIC3:     ' Classic 3
  130.             Call TopMediumBorder(SS, hdrRange, 0)
  131.             Call BottomMediumBorder(SS, hdrRange, 0)
  132.             Call TopMediumBorder(SS, ftrRange, 0)
  133.             Call BottomMediumBorder(SS, ftrRange, 0)
  134.             Call OutlineMediumBorder(SS, .Selection, 0)
  135.             Call SetSolidPattern(SS, col1Range, .PaletteEntry(15), 0)
  136.             Call SetSolidPattern(SS, bodyRange, .PaletteEntry(15), 0)
  137.             Call SetSolidPattern(SS, hdrRange, .PaletteEntry(11), 0)
  138.             Call SetSolidPattern(SS, ftrRange, .PaletteEntry(2), 0)
  139.             Call AdjustFont(SS, hdrRange, RGB(255, 255, 255), True, True, False)
  140.             Call AlignRight(SS, hdrRange)
  141.  
  142.          Case ACCOUNTING1:
  143.             Call TopThinBorder(SS, ftrRange, 0)
  144.             Call BottomThinBorder(SS, hdrRange, 0)
  145.             Call BottomDoubleBorder(SS, ftrRange, 0)
  146.             Call AdjustFont(SS, hdrRange, QBColor(2), True, True, False)
  147.             Call AlignRight(SS, hdrRange)
  148.             Call SetNumberFormat(SS, bodyRange, "#,##0.00_);(#,##0.00)")
  149.             Call SetNumberFormat(SS, ftrRange, "$ #,##0.00_);($ #,##0.00)")
  150.             savedSelection = .Selection
  151.             .SetSelection .SelStartRow + 1, .SelStartCol + 1, .SelStartRow + 1, .SelEndCol
  152.             Call SetNumberFormat(SS, .Selection, "$ #,##0.00_);($ #,##0.00)")
  153.             .Selection = savedSelection
  154.  
  155.          Case ACCOUNTING2:
  156.             Call TopThickBorder(SS, hdrRange, .PaletteEntry(13))
  157.             Call BottomThickBorder(SS, ftrRange, .PaletteEntry(13))
  158.             Call TopThinBorder(SS, ftrRange, .PaletteEntry(13))
  159.             Call BottomThinBorder(SS, hdrRange, .PaletteEntry(13))
  160.             Call AlignRight(SS, hdrRange)
  161.             Call SetNumberFormat(SS, bodyRange, "#,##0.00_);(#,##0.00)")
  162.             Call SetNumberFormat(SS, ftrRange, "$ #,##0.00_);($ #,##0.00)")
  163.             savedSelection = .Selection
  164.             .SetSelection .SelStartRow + 1, .SelStartCol + 1, .SelStartRow + 1, .SelEndCol
  165.             Call SetNumberFormat(SS, .Selection, "$ #,##0.00_);($ #,##0.00)")
  166.             .Selection = savedSelection
  167.  
  168.          Case ACCOUNTING3:
  169.             Call BottomMediumBorder(SS, hdrRange, .PaletteEntry(13))
  170.             savedSelection = .Selection
  171.             .SetSelection .SelEndRow, .SelStartCol + 1, .SelEndRow, .SelEndCol
  172.             Call TopThinBorder(SS, .Selection, 0)
  173.             Call BottomDoubleBorder(SS, .Selection, 0)
  174.             .Selection = savedSelection
  175.             Call AdjustFont(SS, hdrRange, 0, False, True, False)
  176.             Call AdjustFont(SS, col1Range, 0, False, True, False)
  177.             Call AlignRight(SS, hdrRange)
  178.             Call SetNumberFormat(SS, bodyRange, "#,##0.00_);(#,##0.00)")
  179.             Call SetNumberFormat(SS, ftrRange, "$ #,##0.00_);($ #,##0.00)")
  180.             savedSelection = .Selection
  181.             .SetSelection .SelStartRow + 1, .SelStartCol + 1, .SelStartRow + 1, .SelEndCol
  182.             Call SetNumberFormat(SS, .Selection, "$ #,##0.00_);($ #,##0.00)")
  183.             .Selection = savedSelection
  184.  
  185.          Case COLORFUL1:     ' Colorful 1
  186.             Call BottomThinBorder(SS, .Selection, .PaletteEntry(8))
  187.             Call SetSolidPattern(SS, .Selection, .PaletteEntry(14), 0)
  188.             Call SetSolidPattern(SS, col1Range, .PaletteEntry(11), 0)
  189.             Call SetSolidPattern(SS, hdrRange, 0, 0)
  190.             Call OutlineMediumBorder(SS, .Selection, .PaletteEntry(14))
  191.             Call AdjustFont(SS, .Selection, RGB(255, 255, 255), False, False, False)
  192.             Call AdjustFont(SS, col1Range, RGB(255, 255, 255), True, True, False)
  193.             Call AdjustFont(SS, hdrRange, RGB(255, 255, 255), True, True, False)
  194.             Call AlignCenter(SS, hdrRange)
  195.  
  196.          Case COLORFUL2:     ' Colorful 2
  197.             Call TopMediumBorder(SS, hdrRange, 0)
  198.             Call BottomMediumBorder(SS, ftrRange, 0)
  199.             Call TopThinBorder(SS, ftrRange, 0)
  200.             Call BottomThinBorder(SS, hdrRange, 0)
  201.             Call SetHatchPattern4(SS, .Selection, .PaletteEntry(6), .PaletteEntry(2))
  202.             Call SetSolidPattern(SS, hdrRange, .PaletteEntry(9), 0)
  203.             Call AdjustFont(SS, hdrRange, RGB(255, 255, 255), True, True, False)
  204.             Call AdjustFont(SS, col1Range, 0, True, True, False)
  205.             Call AlignRight(SS, hdrRange)
  206.  
  207.          Case COLORFUL3:    ' Colorful 3
  208.             Call SetSolidPattern(SS, .Selection, 0, 0)
  209.             Call AdjustFont(SS, .Selection, QBColor(15), False, False, False)
  210.             Call AdjustFont(SS, hdrRange, QBColor(7), True, True, False)
  211.             Call AdjustFont(SS, col1Range, QBColor(13), True, True, False)
  212.             Call AlignRight(SS, hdrRange)
  213.  
  214.          Case COLORFUL4:    ' Colorful 4
  215.             Call TopThinBorder(SS, ftrRange, 0)
  216.             Call RightThinBorder(SS, col1Range, 0)
  217.             Call OutlineMediumBorder(SS, .Selection, 0)
  218.             Call SetHatchPattern4(SS, .Selection, .PaletteEntry(6), .PaletteEntry(2))
  219.             Call SetSolidPattern(SS, hdrRange, 0, 0)
  220.             Call AdjustFont(SS, hdrRange, QBColor(14), True, True, False)
  221.             Call AdjustFont(SS, col1Range, QBColor(1), True, True, False)
  222.             Call AlignRight(SS, hdrRange)
  223.  
  224.          '' The list formats don't fit into the 5 range schema. It would
  225.          '' be better to use ranges by number instead of string.
  226.          Case LIST1:
  227.             Call OutlineThinBorder(SS, .Selection, .PaletteEntry(14))
  228.             Call SetSolidPattern(SS, hdrRange, .PaletteEntry(14), 0)
  229.             Call SetSolidPattern(SS, ftrRange, .PaletteEntry(14), 0)
  230.             For i = .SelStartRow + 1 To .SelEndRow - 1 Step 2
  231.                Call SetHatchPattern4(SS, _
  232.                   .FormatRCNr(i, .SelStartCol, False) & _
  233.                   ":" & _
  234.                   .FormatRCNr(i, .SelEndCol, False), _
  235.                   .PaletteEntry(19), .PaletteEntry(2))
  236.             Next i
  237.             For i = .SelStartRow + 2 To .SelEndRow - 1 Step 2
  238.                Call SetHatchPattern4(SS, _
  239.                   .FormatRCNr(i, .SelStartCol, False) & _
  240.                   ":" & _
  241.                   .FormatRCNr(i, .SelEndCol, False), _
  242.                   .PaletteEntry(4), .PaletteEntry(2))
  243.             Next i
  244.             Call AdjustFont(SS, hdrRange, QBColor(15), True, True, False)
  245.             Call AdjustFont(SS, ftrRange, QBColor(15), True, False, False)
  246.             Call AlignCenter(SS, hdrRange)
  247.             Call SetNumberFormat(SS, ftrRange, "$ #,##0.00_);($ #,##0.00)")
  248.  
  249.          Case LIST2:
  250.             Call OutlineThinBorder(SS, .Selection, .PaletteEntry(14))
  251.             Call TopThickBorder(SS, hdrRange, .PaletteEntry(14))
  252.             Call BottomThickBorder(SS, ftrRange, .PaletteEntry(14))
  253.             Call TopThinBorder(SS, ftrRange, 0)
  254.             Call BottomThinBorder(SS, hdrRange, 0)
  255.             Call AdjustFont(SS, hdrRange, QBColor(4), True, True, False)
  256.             Call AlignCenter(SS, hdrRange)
  257.             Call SetSolidPattern(SS, hdrRange, .PaletteEntry(15), 0)
  258.             For i = .SelStartRow + 1 To .SelEndRow - 1 Step 2
  259.                Call SetSolidPattern(SS, _
  260.                   .FormatRCNr(i, .SelStartCol, False) & _
  261.                   ":" & _
  262.                   .FormatRCNr(i, .SelEndCol, False), _
  263.                   .PaletteEntry(15), 0)
  264.             Next i
  265.             Call SetNumberFormat(SS, ftrRange, "$ #,##0.00_);($ #,##0.00)")
  266.  
  267.          Case LIST3:
  268.             Call TopMediumBorder(SS, hdrRange, .PaletteEntry(16))
  269.             Call BottomMediumBorder(SS, hdrRange, .PaletteEntry(16))
  270.             Call TopMediumBorder(SS, ftrRange, .PaletteEntry(16))
  271.             Call BottomMediumBorder(SS, ftrRange, .PaletteEntry(16))
  272.             Call AdjustFont(SS, hdrRange, .PaletteEntry(11), True, False, False)
  273.             Call AlignCenter(SS, hdrRange)
  274.  
  275.          Case EFFECTS3D1:    ' 3D Effects 1
  276.             '' Set the back color to black so the 3D effects look good
  277.             .BackColor = .PaletteEntry(15)
  278.             Call SetSolidPattern(SS, .Selection, .PaletteEntry(15), 0)
  279.             '' Here we cheat a little and convert a range string to integers by
  280.             '' setting the current selection.
  281.             savedSelection = .Selection
  282.             .Selection = bodyRange
  283.             Call Inset3DBorder(SS, .SelStartRow, .SelStartCol, .SelEndRow, .SelEndCol)
  284.             .Selection = savedSelection
  285.             Call Raised3DBorder(SS, .SelStartRow, .SelStartCol, .SelEndRow, .SelEndCol)
  286.             Call AdjustFont(SS, hdrRange, .PaletteEntry(13), True, False, False)
  287.             Call AdjustFont(SS, col1Range, 0, True, False, False)
  288.             Call AlignCenter(SS, hdrRange)
  289.  
  290.          Case EFFECTS3D2:
  291.             '' Set the back color to black so the 3D effects look good
  292.             .BackColor = .PaletteEntry(15)
  293.             Call SetSolidPattern(SS, .Selection, .PaletteEntry(15), 0)
  294.             '' Here we cheat a little and convert a range string to integers by
  295.             '' setting the current selection.
  296.             savedSelection = .Selection
  297.             .Selection = bodyRange
  298.             '' Iterate over the rows making every other one inset
  299.             For i = .SelStartRow To .SelEndRow Step 2
  300.                Call Inset3DBorder(SS, i, .SelStartCol, i, .SelEndCol)
  301.             Next i
  302.             '' Now restore the selection
  303.             .Selection = savedSelection
  304.             Call AdjustFont(SS, hdrRange, 0, True, False, False)
  305.             Call AlignCenter(SS, hdrRange)
  306.  
  307.       End Select
  308.  
  309.       '' Adjust column widths in case our number formatting made
  310.       '' some values too wide to fit in the columns.
  311.       .SetColWidthAuto .SelStartRow, .SelStartCol, .SelEndRow, .SelEndCol, True
  312.  
  313.    End With
  314.  
  315.  
  316. End Sub
  317.  
  318. '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  319. '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  320. ''''
  321. '''' Range Definition Functions
  322. ''''
  323. '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  324. '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  325.  
  326. Private Function GetHdrRangeFromSelection(SS As Object) As String
  327. '' Selection is set before calling this function
  328.  
  329.    With SS
  330.       GetHdrRangeFromSelection = _
  331.          .FormatRCNr(.SelStartRow, .SelStartCol, False) _
  332.          & ":" & _
  333.          .FormatRCNr(.SelStartRow, .SelEndCol, False)
  334.    End With
  335.    
  336. End Function
  337.  
  338. Private Function GetFtrRangeFromSelection(SS As Object) As String
  339. '' Selection is set before calling this function
  340.  
  341.    With SS
  342.       GetFtrRangeFromSelection = _
  343.          .FormatRCNr(.SelEndRow, .SelStartCol, False) _
  344.          & ":" & _
  345.          .FormatRCNr(.SelEndRow, .SelEndCol, False)
  346.    End With
  347.  
  348. End Function
  349.  
  350. Private Function GetCol1RangeFromSelection(SS As Object) As String
  351. '' Selection is set before calling this function
  352.  
  353.    With SS
  354.       GetCol1RangeFromSelection = _
  355.          .FormatRCNr(.SelStartRow, .SelStartCol, False) _
  356.          & ":" & _
  357.          .FormatRCNr(.SelEndRow, .SelStartCol, False)
  358.    End With
  359.  
  360. End Function
  361.  
  362. Private Function GetBodyRangeFromSelection(SS As Object)
  363. '' Selection is set before calling this function
  364.  
  365.    With SS
  366.       GetBodyRangeFromSelection = _
  367.          .FormatRCNr(.SelStartRow + 1, .SelStartCol + 1, False) _
  368.          & ":" & _
  369.          .FormatRCNr(.SelEndRow - 1, .SelEndCol, False)
  370.    End With
  371.  
  372. End Function
  373.  
  374. Private Sub SetNumberFormat(SS As Object, range$, nFormat$)
  375.  
  376.    Dim savedSelection$
  377.  
  378.    With SS
  379.       savedSelection = .Selection
  380.       .Selection = range
  381.       .NumberFormat = nFormat
  382.       .Selection = savedSelection
  383.    End With
  384.  
  385. End Sub
  386.  
  387. Private Sub AdjustFont(SS As Object, range$, color&, bold As Boolean, italic As Boolean, underline As Boolean)
  388.  
  389.    Dim fName$, fSize%, savedSelection$
  390.    Dim pBold As Boolean, pItalic As Boolean, pUnderline As Boolean
  391.    Dim pStrikeout As Boolean, pColor&, pOutline As Boolean, pShadow As Boolean
  392.  
  393.    With SS
  394.       savedSelection = .Selection
  395.       .Selection = range
  396.       .GetFont fName, fSize, pBold, pItalic, pUnderline, pStrikeout, pColor, pOutline, pShadow
  397.       .SetFont fName, fSize / 20, bold, italic, underline, False, color, False, False
  398.       .Selection = savedSelection
  399.    End With
  400.  
  401. End Sub
  402.  
  403. '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  404. '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  405. ''''
  406. '''' Alignment Functions
  407. ''''
  408. '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  409. '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  410.  
  411. Private Sub AlignCenter(SS As Object, range$)
  412.  
  413.    Dim savedSelection$
  414.    
  415.    With SS
  416.       savedSelection = .Selection
  417.       .Selection = range
  418.       .SetAlignment F1HAlignCenter, False, F1VAlignBottom, 0
  419.       .Selection = savedSelection
  420.    End With
  421.  
  422. End Sub
  423.  
  424. Private Sub AlignRight(SS As Object, range$)
  425.  
  426.    Dim savedSelection$
  427.  
  428.    With SS
  429.       savedSelection = .Selection
  430.       .Selection = range
  431.       .SetAlignment F1HAlignRight, False, F1VAlignBottom, 0
  432.       .Selection = savedSelection
  433.    End With
  434.  
  435. End Sub
  436.  
  437. '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  438. '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  439. ''''
  440. '''' Border Functions
  441. ''''
  442. '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  443. '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  444.  
  445. Private Sub OutlineThickBorder(SS As Object, range$, color&)
  446.  
  447.    Dim savedSelection$
  448.  
  449.    With SS
  450.       Let savedSelection = .Selection
  451.       .Selection = range
  452.       .SetBorder 5, -1, -1, -1, -1, 0, color, 0, 0, 0, 0
  453.       .Selection = savedSelection
  454.    End With
  455.  
  456. End Sub
  457.  
  458. Private Sub TopThickBorder(SS As Object, range$, color&)
  459.  
  460.    Dim savedSelection$
  461.  
  462.    With SS
  463.       Let savedSelection = .Selection
  464.       .Selection = range
  465.       .SetBorder -1, -1, -1, 5, -1, 0, 0, 0, 0, color, 0
  466.       .Selection = savedSelection
  467.    End With
  468.  
  469. End Sub
  470.  
  471. Private Sub BottomThickBorder(SS As Object, range$, color&)
  472.  
  473.    Dim savedSelection$
  474.  
  475.    With SS
  476.       Let savedSelection = .Selection
  477.       .Selection = range
  478.       .SetBorder -1, -1, -1, -1, 5, 0, 0, 0, 0, 0, color
  479.       .Selection = savedSelection
  480.    End With
  481.  
  482. End Sub
  483.  
  484.  
  485. Private Sub OutlineMediumBorder(SS As Object, range$, color&)
  486.  
  487.    Dim savedSelection$
  488.  
  489.    With SS
  490.       Let savedSelection = .Selection
  491.       .Selection = range
  492.       .SetBorder 2, -1, -1, -1, -1, 0, color, 0, 0, 0, 0
  493.       .Selection = savedSelection
  494.    End With
  495.  
  496. End Sub
  497.  
  498. Private Sub LeftMediumBorder(SS As Object, range$, color&)
  499.  
  500.    Dim savedSelection$
  501.  
  502.    With SS
  503.       Let savedSelection = .Selection
  504.       .Selection = range
  505.       .SetBorder -1, 2, -1, -1, -1, 0, color, 0, 0, 0, 0
  506.       .Selection = savedSelection
  507.    End With
  508.  
  509. End Sub
  510.  
  511. Private Sub TopMediumBorder(SS As Object, range$, color&)
  512.  
  513.    Dim savedSelection$
  514.  
  515.    With SS
  516.       Let savedSelection = .Selection
  517.       .Selection = range
  518.       .SetBorder -1, -1, -1, 2, -1, 0, 0, 0, 0, color, 0
  519.       .Selection = savedSelection
  520.    End With
  521.    
  522. End Sub
  523.  
  524. Private Sub BottomMediumBorder(SS As Object, range$, color&)
  525.  
  526.    Dim savedSelection$
  527.  
  528.    With SS
  529.       Let savedSelection = .Selection
  530.       .Selection = range
  531.       .SetBorder -1, -1, -1, -1, 2, 0, 0, 0, 0, 0, color
  532.       .Selection = savedSelection
  533.    End With
  534.  
  535. End Sub
  536.  
  537. Private Sub OutlineThinBorder(SS As Object, range$, color&)
  538.  
  539.    Dim savedSelection$
  540.  
  541.    With SS
  542.       Let savedSelection = .Selection
  543.       .Selection = range
  544.       .SetBorder 1, -1, -1, -1, -1, 0, color, 0, 0, 0, 0
  545.       .Selection = savedSelection
  546.    End With
  547.  
  548. End Sub
  549.  
  550. Private Sub RightThinBorder(SS As Object, range$, color&)
  551.  
  552.    Dim savedSelection$
  553.  
  554.    With SS
  555.       Let savedSelection = .Selection
  556.       .Selection = range
  557.       .SetBorder -1, -1, 1, -1, -1, 0, 0, 0, color, 0, 0
  558.       .Selection = savedSelection
  559.    End With
  560.  
  561. End Sub
  562.  
  563. Private Sub TopThinBorder(SS As Object, range$, color&)
  564.  
  565.    Dim savedSelection$
  566.  
  567.    With SS
  568.       Let savedSelection = .Selection
  569.       .Selection = range
  570.       .SetBorder -1, -1, -1, 1, -1, 0, 0, 0, 0, color, 0
  571.       .Selection = savedSelection
  572.    End With
  573.  
  574. End Sub
  575.  
  576. Private Sub BottomThinBorder(SS As Object, range$, color&)
  577.  
  578.    Dim savedSelection$
  579.  
  580.    With SS
  581.       Let savedSelection = .Selection
  582.       .Selection = range
  583.       .SetBorder -1, -1, -1, -1, 1, 0, 0, 0, 0, 0, color
  584.       .Selection = savedSelection
  585.    End With
  586.  
  587. End Sub
  588.  
  589. Private Sub BottomDoubleBorder(SS As Object, range$, color&)
  590.  
  591.    Dim savedSelection$
  592.  
  593.    With SS
  594.       Let savedSelection = .Selection
  595.       .Selection = range
  596.       .SetBorder -1, -1, -1, -1, 6, 0, 0, 0, 0, 0, color
  597.       .Selection = savedSelection
  598.    End With
  599.  
  600. End Sub
  601.  
  602. '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  603. '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  604. ''''
  605. '''' 3D Effect Functions
  606. ''''
  607. '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  608. '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  609.  
  610. Private Sub Inset3DBorder(SS As Object, r1&, c1&, r2&, c2&)
  611.  
  612.    Dim savedSelection$
  613.  
  614.    With SS
  615.       Let savedSelection = .Selection
  616.       .SetSelection r1, c1, r2, c2
  617.       .SetBorder 2, -1, -1, -1, -1, -1, .PaletteEntry(48), 0, 0, 0, 0
  618.       .SetSelection r1, c2, r2, c2
  619.       .SetBorder -1, -1, 2, -1, -1, 0, 0, 0, .PaletteEntry(2), 0, 0
  620.       .SetSelection r2, c1, r2, c2
  621.       .SetBorder -1, -1, -1, -1, 2, 0, 0, 0, 0, 0, .PaletteEntry(2)
  622.       .Selection = savedSelection
  623.    End With
  624.  
  625. End Sub
  626.  
  627. Private Sub Raised3DBorder(SS As Object, r1&, c1&, r2&, c2&)
  628.  
  629.    Dim savedSelection$
  630.  
  631.    With SS
  632.       Let savedSelection = .Selection
  633.       .SetSelection r1, c1, r2, c2
  634.       .SetBorder 2, -1, -1, -1, -1, -1, .PaletteEntry(2), 0, 0, 0, 0
  635.       .SetSelection r1, c2, r2, c2
  636.       .SetBorder -1, -1, 2, -1, -1, 0, 0, 0, .PaletteEntry(48), 0, 0
  637.       .SetSelection r2, c1, r2, c2
  638.       .SetBorder -1, -1, -1, -1, 2, 0, 0, 0, 0, 0, .PaletteEntry(48)
  639.       .Selection = savedSelection
  640.    End With
  641.  
  642. End Sub
  643.  
  644. '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  645. '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  646. ''''
  647. '''' Pattern Functions
  648. ''''
  649. '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  650. '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
  651.  
  652. Private Sub SetSolidPattern(SS As Object, range$, fcolor&, bcolor&)
  653.  
  654.    Dim savedSelection$
  655.  
  656.    With SS
  657.       Let savedSelection = .Selection
  658.       .Selection = range
  659.       .SetPattern 1, fcolor, bcolor
  660.       .Selection = savedSelection
  661.    End With
  662.    
  663. End Sub
  664.  
  665. Private Sub SetHatchPattern4(SS As Object, range$, fcolor&, bcolor&)
  666.  
  667.    Dim savedSelection$
  668.  
  669.    With SS
  670.       Let savedSelection = .Selection
  671.       .Selection = range
  672.       .SetPattern 4, fcolor, bcolor
  673.       .Selection = savedSelection
  674.    End With
  675.  
  676. End Sub
  677.  
  678.